<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>添加试题</title>
<%@include file="../core/head.jsp"%>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="${ctx}/css/core.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/exam.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/buttons.css" type="text/css">
<link rel="stylesheet" href="${ctx}/css/table.css" type="text/css">
<script type="text/javascript" src="${ctx }/js/FusionCharts.js"></script>
<script type="text/javascript">

function addPaper(boo){
	$("#isEditQuestions").val(boo?"true":"false");
	$("#mainForm").submit();
	
}
var ready = {};
function showPapers( ){
	var type = $("#type").val();
	if(ready["PAPER-"+type]){
		return;
	}
	var url = "${ctx}/exam/findPapers.action";
	$.post(url,{"paper.type":type} ,
	function listPaper(paper){
 		var div = $("#choose");
		div.empty();
		div.append("<option value='0'>自定义添加</option>");
		for(var i = 0;i<paper.length;i++){
			var p = paper[i];
			var item = $("<option  value='"+p.id+"'>"+p.title+"</option>");
			div.append(item);
		}
		ready["PAPER-"+type]=true;
	});
}
function selectOne(sel){
	var title = $(sel).find("option:selected").text();
	$("#ptitle").val(title);
	$("#paperId").val(sel.value ==0?'':sel.value) ;
}
var myChart;
$(function(){
	showPapers();
	myChart= new FusionCharts("${ctx}/charts/Doughnut3D.swf", "myChartId", 500, 300);
	getStaticInfos();
});

function getStaticInfos(){
	var type = $("#type").val();
	var url = "${ctx}/exam/getPaperInfo.action";
	$.post(url,{"paper.type":type} ,
	function showChart(staticInfos){
	var dataxml = "<chart   decimals='1' showLabels='1' useRoundEdges='1' formatNumberScale='0' baseFont='宋体' showValues='1' caption='题库分布' pieSliceDepth='20' baseFontSize='12'     pieRadius='130' >";
	for(i in staticInfos){
		var info = staticInfos[i];
		dataxml=dataxml+"<set name='" +info.title+"' value='"+info.num+"'  />";
	 	  
	 }
	
	dataxml= dataxml+ "</chart>";
	myChart.setDataXML(dataxml);    
	myChart.render("chartdiv");
	 
	});
	
}


</script>

<style type="text/css">

#upFile{
display: none;
}
#upText{

}


</style>
</head>

<body>
<%@include file="top.jsp"%>
<div class="width center menuPanel radius">
	<div class="upload center" align="center">
		<div class="left" style="width: 450px">
		<form action="${ctx }/exam/addPaper.action" id="mainForm" method="post"  >
			<input type="hidden" id="isEditQuestions" name="editQuestions" value = "false"/>
			<table class="table" style="width: 400px;"  >
				<tr><th>考试类型:</th>
					<td>
						<select id="type" name="paper.type" onchange="showPapers()">
							<z:dic code="" isType="true" init="${paper.type}" />
						</select>
					</td>
				</tr>
				<tr><th>试卷名称:</th>
					<td>
						 
						<input type="hidden"  id="paperId" name="paper.id"  value="${paper.id}"/> 
						<div style="position: relative;">
							<input type="text" id="ptitle" onchange="$('#paperId').val('');" autocomplete="off"  name="paper.title"    /> 
							<select id="choose" onchange="selectOne(this)" >
								
							</select>
						</div>
					</td>
				</tr>
				<z:auth type='admin'>
					<tr><th>文件名称:</th><td><input type="text" name="fileName" /> </td></tr>
				</z:auth>
				
				<tr><th>试卷状态:</th>
					<td>
						<label><input type="radio" name="paper.state" value="0" checked="checked"/>公共试卷</label> 
						<label><input type="radio" name="paper.state" value="1"/>私有试卷</label> 
					</td>
				</tr>
				
				<tr><th></th>
					<td>
						<div style="height: 24px">
							<s:fielderror fieldName="paper.title" cssClass="errorInfo"/> 
						</div>
					</td>
				 </tr>
				 
				<tr>  
				<th></th>
				<td>
					<input type="button" onclick="addPaper();" class="button green menuBut" value="添加试题"/>
					<z:auth type='admin'>
					<input type="button" onclick="addPaper(true);" class="button green menuBut" value="编辑试题"/>
					</z:auth>
				</td>
				</tr>
			</table>
		</form> 
		</div>
		<div  style="width:500px; margin-top: -20px;" class="right">
			<div id="chartdiv" ></div>
		</div>
		<div class="clear"></div>
	</div>
</div>
<%@include file="../core/bottom.jsp"%> 
	
</body>
</html>
